﻿using LoverMeeting.DataBase;
using Microsoft.Practices.Unity;
using Microsoft.Practices.ServiceLocation;
using LoverMeeting.Model.Service;
using LoverMeeting.Model.Repository;
using LoverMeeting.Core.Security;

namespace LoverMeeting.Configuration.Mapping
{
    public class Mapping
    {
        public void RegisterMapping()
        {
            var locator = new UnityServiceLocator(ConfigureUnityContainer());
            ServiceLocator.SetLocatorProvider(() => locator);
        }

        private UnityContainer ConfigureUnityContainer()
        {
            var container = new UnityContainer();
            ConfigureService(container);
            ConfigureDataBase(container);
            return container;
        }

        private void ConfigureService(IUnityContainer container)
        {
            container.RegisterType<ICrypto, Crypto>();
        }

        private void ConfigureDataBase(IUnityContainer container)
        {
            container.RegisterType<IGenderRepository, GenderRepository>();
            container.RegisterType<IDesiredGenderRepository, DesiredGenderRepository>();
            container.RegisterType<ILoverHeightRepository, LoverHeightRepository>();
            container.RegisterType<ILoverWeightRepository, LoverWeightRepository>();
            container.RegisterType<IMaritalStatusRepository, MaritalStatusRepository>();
            container.RegisterType<IRelationshipTypeRepository, RelationshipTypeRepository>();
            container.RegisterType<ILoverRepository, LoverRepository>();
        }
    }
}

